<template>
  <router-view />
</template>
<script setup>
import { watch, onMounted } from "vue";
import useUserStore from "@/store/modules/user";
import { setLocalCache } from "@/utils/cache";
import defaultConfig from "@/settings";
import useReceiveMainData from "@/hooks/microApp/useReceiveMainData";
import { isMicroApp } from "@/microApp";

import useCodeArrStore from "@/store/modules/select";
import { getOptionselect } from "@/apis/login";

const getCodeArr = () => {
  getOptionselect().then(res => {
    useCodeArrStore().setDict(res.data);
  });
};

const getMainAppData = () => {
  if (isMicroApp()) {
    const userStore = useUserStore();
    const { userInfo, token, roles } = useReceiveMainData();
    userStore.userInfo = userInfo?.value || {};
    userStore.roles = roles?.value || [];
    setLocalCache(defaultConfig.tokenAttr, token?.value || "");
  }
};
onMounted(() => {
  getMainAppData();
  getCodeArr();
  // const app = document.getElementById("designer-app");
  // console.log(app, "222222222222", window.innerWidth, window.innerHeight);
  // app.style.height = window.innerHeight + 300 + "px";
});
</script>
<style>
#designer-app {
  height: 100%;
  font-weight: 400;
  overflow: scroll;
}

html,
body {
  margin: 0;
  padding: 0;
  background: #f8fafb;
}
</style>
